<template>
  <div class="const">
    <el-container>
  <el-aside width="200px">
    <img src="https://slwl-admin.itheima.net/static/img/logo.58dd185e.png" alt="" class="tupian">
    <el-menu
          router
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          text-color="#333"
          unique-opened
          style="text-align: left;"
        >
        <el-menu-item index="/dashboard">
            <span slot="title">工作台</span>
          </el-menu-item>
          <el-submenu
          :index="item.id + ''"
          v-for="item in menuList"
          :key="item.id"
          v-if="item.children"
          >
            <template slot="title">
              <span>{{ item.name }}</span>
            </template>
            <el-menu-item
              :index="itemson.path"
              v-for="itemson in item.children"
              :key="itemson.id"
              @click="open(itemson)"
            >
              <template slot="title">
                <span>{{ itemson.name }}</span>
              </template>
              </el-menu-item>
          </el-submenu>
        </el-menu>
  </el-aside>
  <el-container>
    <el-header>
   <div style="display: flex; justify-content: space-between; height: 60px;">
    <i>{{title}}</i>
    <div style="display: inline-block; height: 30px;">
     <img src="https://slwl-admin.itheima.net/static/img/default.c29a19ca.jpg" alt="" class="ppp">
    <span style="margin-right: 20px;">神领管理员</span>
    <span style="margin-right: 20px;">|</span>
    <img @click="logout"  style="position: relative; top: 5px; cursor: pointer;" src="" alt="">
    </div>
   </div>
    </el-header>
    <el-main>
      <router-view/>
    </el-main>
  </el-container>
</el-container>
  </div>
</template>
<script>
import { getmenuApi } from '@/api/login';
export default {
  data() {
    return {
      menuList: [],
      title:''
    }
  },
  created() {
    this.menulist()
  },
  methods: {
    logout() {
      this.$store.commit("user/logout");
      this.$router.push("/login");
    },
   async menulist() {
     const res = await getmenuApi()
     console.log(res);
     this.menuList=res.data
   },
   handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    open(itemson) {
      this.title=itemson.name
    }
  }
}
</script>
<style lang="scss" scoped>

.const{
  .el-header {
    background-color: #f3f4f7;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  
  .el-aside {
    background-color: #ffffff;
    color: #333;
    text-align: center;
    // line-height: 200px;
  }
  
  .el-main {
    background-color: #f3f4f7;
    color: #333;
  }
  
  body > .el-container {
    margin-bottom: 40px;
  }
  .el-container{
    min-height: 100vh;
  }
  .tupian{
    width: 152px;
    height: 113px;
    margin-top: 10px;
  }
  .tou{
    width: 30px;
    height: 30px;
  }
  .title{
    float: left;
  }
  .logout{
    float: right;
  }
  .ppp{
    cursor: pointer;
    width: 30px; 
    height: 30px; 
    margin-right: 20px; 
    border-radius: 30px; 
    position: relative; top: 10px;
  }
}

  
  
</style>